# coding:utf-8
# writingtime: 2022-6-27
# author: wanjun
# reference:
# doi:
# examiner:
import os
from Utilities.AutoGetOperator.selectPackage import get_func

getSimilarity=get_func(r'Measure\similarity\getSimilarity.py','getSimilarity')  # 相似度函数的获取


def getPostiveWeight(matrix_list,q=3):
    '''正理想计算专家权重'''
    length=len(matrix_list)
    m,n=len(matrix_list[0]),len(matrix_list[0][0])
    postive=([1,1],[0,0])
    sum1_1=0
    li=[]
    for k in range(length):     # 对专家的遍历
        for i in range(m):      # 对方案的遍历
            for j in range(n):  # 对属性的遍历
                sum1_1+=getSimilarity([matrix_list[k][i][j]],[postive],q)
        li.append(sum1_1)

    lis=[i/sum(li) for i in li]

    return lis



if __name__=='__main__':
    a1 = [
        [([0.85, 0.9], [0.15, 0.25]), ([0.75, 0.85], [0.2, 0.3]), ([0.75, 0.8], [0.25, 0.3]),
         ([0.7, 0.75], [0.3, 0.35]),
         ([0.6, 0.65], [0.4, 0.5])],
        [([0.9, 0.95], [0.1, 0.2]), ([0.8, 0.85], [0.15, 0.2]), ([0.75, 0.85], [0.2, 0.3]), ([0.75, 0.8], [0.25, 0.3]),
         ([0.65, 0.7], [0.35, 0.45])],
        [([0.8, 0.85], [0.15, 0.2]), ([0.75, 0.8], [0.25, 0.3]), ([0.7, 0.75], [0.35, 0.4]), ([0.65, 0.7], [0.35, 0.4]),
         ([0.6, 0.65], [0.35, 0.4])],
        [([0.75, 0.85], [0.2, 0.3]), ([0.7, 0.75], [0.25, 0.3]), ([0.65, 0.75], [0.2, 0.3]), ([0.6, 0.65], [0.3, 0.4]),
         ([0.6, 0.65], [0.3, 0.4])],
        [([0.7, 0.8], [0.2, 0.3]), ([0.7, 0.75], [0.3, 0.4]), ([0.6, 0.7], [0.3, 0.4]), ([0.6, 0.65], [0.4, 0.5]),
         ([0.5, 0.6], [0.45, 0.55])]]
    a2 = [
        [([0.8, 0.85], [0.2, 0.25]), ([0.75, 0.8], [0.25, 0.3]), ([0.7, 0.75], [0.25, 0.3]),
         ([0.65, 0.75], [0.25, 0.35]),
         ([0.6, 0.7], [0.3, 0.4])],
        [([0.85, 0.9], [0.1, 0.2]), ([0.75, 0.85], [0.2, 0.3]), ([0.7, 0.8], [0.25, 0.3]), ([0.7, 0.8], [0.2, 0.3]),
         ([0.6, 0.65], [0.35, 0.5])],
        [([0.75, 0.85], [0.2, 0.25]), ([0.75, 0.8], [0.2, 0.25]), ([0.65, 0.75], [0.25, 0.35]),
         ([0.65, 0.7], [0.25, 0.3]),
         ([0.55, 0.65], [0.4, 0.5])],
        [([0.75, 0.85], [0.25, 0.3]), ([0.7, 0.8], [0.2, 0.3]), ([0.7, 0.75], [0.3, 0.35]), ([0.65, 0.75], [0.3, 0.4]),
         ([0.6, 0.65], [0.4, 0.5])],
        [([0.75, 0.8], [0.25, 0.3]), ([0.7, 0.75], [0.35, 0.4]), ([0.65, 0.7], [0.35, 0.4]), ([0.6, 0.7], [0.4, 0.5]),
         ([0.55, 0.6], [0.4, 0.5])]]
    a3 = [
        [([0.75, 0.85], [0.15, 0.25]), ([0.75, 0.8], [0.2, 0.25]), ([0.7, 0.75], [0.25, 0.3]),
         ([0.65, 0.75], [0.3, 0.4]),
         ([0.55, 0.6], [0.45, 0.5])],
        [([0.8, 0.85], [0.15, 0.2]), ([0.75, 0.85], [0.2, 0.3]), ([0.75, 0.8], [0.25, 0.3]), ([0.7, 0.8], [0.2, 0.3]),
         ([0.6, 0.65], [0.4, 0.5])],
        [([0.75, 0.85], [0.2, 0.25]), ([0.7, 0.8], [0.2, 0.3]), ([0.7, 0.75], [0.35, 0.4]), ([0.65, 0.7], [0.35, 0.4]),
         ([0.6, 0.65], [0.35, 0.5])],
        [([0.75, 0.8], [0.2, 0.25]), ([0.7, 0.8], [0.25, 0.3]), ([0.7, 0.75], [0.3, 0.4]), ([0.65, 0.7], [0.3, 0.4]),
         ([0.5, 0.55], [0.45, 0.5])],
        [([0.75, 0.8], [0.2, 0.3]), ([0.7, 0.75], [0.2, 0.3]), ([0.65, 0.7], [0.35, 0.4]), ([0.6, 0.65], [0.35, 0.4]),
         ([0.55, 0.6], [0.45, 0.5])]]
    a4 = [
        [([0.8, 0.85], [0.1, 0.2]), ([0.75, 0.8], [0.2, 0.25]), ([0.7, 0.75], [0.25, 0.3]), ([0.65, 0.75], [0.3, 0.4]),
         ([0.5, 0.55], [0.45, 0.5])],
        [([0.85, 0.9], [0.15, 0.2]), ([0.8, 0.85], [0.15, 0.2]), ([0.75, 0.8], [0.25, 0.3]), ([0.7, 0.75], [0.2, 0.3]),
         ([0.65, 0.7], [0.3, 0.35])],
        [([0.75, 0.85], [0.2, 0.3]), ([0.75, 0.8], [0.25, 0.3]), ([0.65, 0.75], [0.3, 0.4]), ([0.65, 0.7], [0.35, 0.4]),
         ([0.55, 0.6], [0.45, 0.5])],
        [([0.75, 0.8], [0.25, 0.3]), ([0.7, 0.8], [0.25, 0.3]), ([0.7, 0.75], [0.35, 0.4]), ([0.65, 0.7], [0.35, 0.4]),
         ([0.55, 0.6], [0.4, 0.5])],
        [([0.7, 0.75], [0.2, 0.3]), ([0.65, 0.75], [0.3, 0.4]), ([0.6, 0.65], [0.4, 0.5]), ([0.55, 0.65], [0.5, 0.6]),
         ([0.45, 0.5], [0.5, 0.55])]]

    a_list=[a1,a2,a3,a4]
    q=3
    list1=[]
    print('参考正理想得到的权重',(getPostiveWeight(a_list, q)))
